package com.test.demo.config;

import com.test.demo.filter.ValidatorFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 过滤器的注册类
 * @author zx
 */
//@Configuration
public class WebFilterConfig {

    private static final Logger log = LoggerFactory.getLogger(WebFilterConfig.class);
    @Bean
    public FilterRegistrationBean ValidatorFilterRegistration() {
        //新建过滤器注册类
        FilterRegistrationBean registration = new FilterRegistrationBean();
        // 添加我们写好的过滤器
        registration.setFilter(new ValidatorFilter());
        // 设置过滤器的URL模式
        registration.addUrlPatterns("/*");
        registration.setOrder(1);
        log.info("自定义过滤器加载完成");
        return registration;
    }


}
